﻿using Dark_Core_Library.DatabaseModules.MongoDB;
using MongoDB.Bson.Serialization.Attributes;
using MongoDB.Bson;

namespace DetectWebApi.Models.User
{
    /// <summary>
    /// 用户文档
    /// </summary>
    public class UserDocument : DocumentUnit
    {
        /// <summary>
        /// 账户
        /// </summary>
        [BsonElement("UserName")]
        [BsonRepresentation(BsonType.String)]
        public string UserName { set; get; }
        /// <summary>
        /// 密码
        /// </summary>
        [BsonElement("Password")]
        [BsonRepresentation(BsonType.String)]
        public string Password { set; get; }
        /// <summary>
        /// 等级
        /// </summary>
        [BsonElement("Level")]
        [BsonRepresentation(BsonType.Int64)]
        public int Level { set; get; }

        private UserDocument(string username,string password,int level)
        {
            this.UserName = username;
            this.Password = password;
            this.Level = level;
        }



        /// <summary>
        /// zh-cn: 转换为文档
        /// en: Convert to document
        /// </summary>
        /// <param name="sUser">简单用户对象</param>
        /// <returns>用户文档</returns>
        public static UserDocument ToDocument(SUserDocument sUser) => new UserDocument(sUser.User, sUser.Pass, 0);
    }

    /// <summary>
    /// 简单用户文档
    /// </summary>
    /// <param name="User">账号</param>
    /// <param name="Pass">密码</param>
    public record SUserDocument(string User, string Pass);

    /// <summary>
    /// 用户查询模式
    /// </summary>
    public enum UserQueryMode
    {
        /// <summary>
        /// 查询所有
        /// </summary>
        All,
        /// <summary>
        /// 按ID查询
        /// </summary>
        Id,
        /// <summary>
        /// 按用户名查询
        /// </summary>
        Username,
        /// <summary>
        /// 模糊查询手机号
        /// </summary>
        FuzzyPhone,
        /// <summary>
        /// 模糊查询部门
        /// </summary>
        FuzzyDepartment,
        /// <summary>
        /// 模糊查询负责项目
        /// </summary>
        FuzzyResponsibleProject,

    }
}
